package com.jyxd.web.service.assessment.basic;

import com.jyxd.web.dao.basic.RecordListDao;
import com.jyxd.web.dao.basic.RecordListItemDao;
import com.jyxd.web.data.basic.RecordList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class RecordListService {

    @Autowired
    private RecordListDao recordListDao;
    @Autowired
    private RecordListItemDao recordListItenDao;

    /**
     * 新增一条记录表数据
     * @param RecordList
     * @return boolean
     */
    public boolean insert(RecordList RecordList){
        return recordListDao.insert(RecordList);
    }


    /**
     * 删除一条记录表数据
     * @param map
     * @return boolean
     */
    public boolean delete( Map<String,Object> map){
        boolean flag = false;
        RecordList recordList = recordListDao.queryDataById(map);
        recordList.setStatus(Integer.valueOf(map.get("status").toString()));
        boolean update = recordListDao.update(recordList);
        if (update){
            map.put("recordListId",recordList.getId());
             flag = recordListItenDao.deleteByRecordListId(map);
        }
        return flag;
    }

    /**
     * 根据条件分页查询记录表数据
     * @param map
     * @return list
     */
    public List<RecordList> queryList(Map<String, Object> map){
        return recordListDao.queryList(map);
    }

    /**
     * 根据条件查询记录表总数
     * @param map
     * @return
     */
    public int queryNum(Map<String, Object> map){
        return recordListDao.queryNum(map);
    }


}
